package com.changcheng.project.handsetlistinfo.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.changcheng.framework.aspectj.lang.annotation.Log;
import com.changcheng.framework.aspectj.lang.enums.BusinessType;
import com.changcheng.project.handsetlistinfo.domain.AHandsetList;
import com.changcheng.project.handsetlistinfo.service.IAHandsetListService;
import com.changcheng.framework.web.controller.BaseController;
import com.changcheng.framework.web.domain.AjaxResult;
import com.changcheng.common.utils.poi.ExcelUtil;
import com.changcheng.framework.web.page.TableDataInfo;

/**
 * 手持机列表Controller
 * 
 * @author dazhi
 * @date 2020-10-30
 */
@Controller
@RequestMapping("/handsetlist/handsetlistinfo")
public class AHandsetListController extends BaseController
{
    private String prefix = "handsetlist/handsetlistinfo";

    @Autowired
    private IAHandsetListService aHandsetListService;

    @RequiresPermissions("handsetlist:handsetlistinfo:view")
    @GetMapping()
    public String handsetlistinfo()
    {
        return prefix + "/handsetlistinfo";
    }

    /**
     * 查询手持机列表列表
     */
    @RequiresPermissions("handsetlist:handsetlistinfo:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(AHandsetList aHandsetList)
    {
        startPage();
        List<AHandsetList> list = aHandsetListService.selectAHandsetListList(aHandsetList);
        return getDataTable(list);
    }

    /**
     * 导出手持机列表列表
     */
    @RequiresPermissions("handsetlist:handsetlistinfo:export")
    @Log(title = "手持机列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(AHandsetList aHandsetList)
    {
        List<AHandsetList> list = aHandsetListService.selectAHandsetListList(aHandsetList);
        ExcelUtil<AHandsetList> util = new ExcelUtil<AHandsetList>(AHandsetList.class);
        return util.exportExcel(list, "handsetlistinfo");
    }

    /**
     * 新增手持机列表
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存手持机列表
     */
    @RequiresPermissions("handsetlist:handsetlistinfo:add")
    @Log(title = "手持机列表", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(AHandsetList aHandsetList)
    {
        return toAjax(aHandsetListService.insertAHandsetList(aHandsetList));
    }

    /**
     * 修改手持机列表
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        AHandsetList aHandsetList = aHandsetListService.selectAHandsetListById(id);
        mmap.put("aHandsetList", aHandsetList);
        return prefix + "/edit";
    }

    /**
     * 修改保存手持机列表
     */
    @RequiresPermissions("handsetlist:handsetlistinfo:edit")
    @Log(title = "手持机列表", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(AHandsetList aHandsetList)
    {
        return toAjax(aHandsetListService.updateAHandsetList(aHandsetList));
    }

    /**
     * 删除手持机列表
     */
    @RequiresPermissions("handsetlist:handsetlistinfo:remove")
    @Log(title = "手持机列表", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(aHandsetListService.deleteAHandsetListByIds(ids));
    }
}
